home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dviselect / fio.h < prev    next >
Text File  |  1989-06-15  |  1KB  |  49 lines

  1. /*
  2.  * Copyright (c) 1987 University of Maryland Department of Computer Science.
  3.  * All rights reserved.  Permission to copy for any purpose is hereby granted
  4.  * so long as this copyright notice remains intact.
  5.  */
  6.  
  7. /*
  8.  * File I/O: numbers.
  9.  *
  10.  * We deal in fixed format numbers and (FILE *)s here.
  11.  * For pointer I/O, see pio.h.
  12.  *
  13.  * N.B.: These do the `wrong thing' at EOF.  It is imperative
  14.  * that the caller add appropriate `if (feof(fp))' statements.
  15.  */
  16.  
  17. /*
  18.  * Get one unsigned byte.  Note that this is a proper expression.
  19.  * The reset have more limited contexts, and are therefore OddLy
  20.  * CapItaliseD.
  21.  */
  22. #define    fgetbyte(fp)    (getc(fp))
  23.  
  24. /*
  25.  * Get a two-byte unsigned integer, a three-byte unsigned integer,
  26.  * or a four-byte signed integer.
  27.  */
  28. #define fGetWord(fp, r)    ((r)  = getc(fp) << 8,  (r) |= getc(fp))
  29. #define fGet3Byte(fp,r) ((r)  = getc(fp) << 16, (r) |= getc(fp) << 8, \
  30.              (r) |= getc(fp))
  31. #define fGetLong(fp, r)    ((r)  = getc(fp) << 24, (r) |= getc(fp) << 16, \
  32.              (r) |= getc(fp) << 8,  (r) |= getc(fp))
  33.  
  34. /*
  35.  * Fast I/O write (and regular write) macros.
  36.  */
  37. #define    putbyte(fp, r)    (putc((r), fp))
  38.  
  39. #define PutWord(fp, r)    (putc((r) >> 8,  fp), putc((r), fp))
  40. #define Put3Byte(fp, r)    (putc((r) >> 16, fp), putc((r) >> 8, fp), \
  41.              putc((r), fp))
  42. #define PutLong(fp, r)    (putc((r) >> 24, fp), putc((r) >> 16, fp), \
  43.              putc((r) >> 8, fp),  putc((r), fp))
  44.  
  45. /*
  46.  * Function types
  47.  */
  48. i32    GetByte(), GetWord(), Get3Byte(), GetLong();
  49.